<template>
  <!--  交强险保司报价审批-->
  <el-form :model="ruleForm"  ref="ruleForm" :inline="false"
            class="elForm">
    <!--交强险信息-->
    <el-card class="box-card"  shadow="never">

      <div slot="header" class="header-card">
        <span class="header-card-title">交强险信息</span>
      </div>

      <!--保司报价审批点-->
      <el-row :gutter="24" >
        <el-col :span="8">
          <el-form-item label="租赁禀议保险公司:">
            <span>{{ ruleForm.rentInsuranceCompany }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="投保渠道:">
            <span>{{ selectDictLabel(dict.type.insurance_channels, ruleForm.insuranceChannels) }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="交强险公司:">
            <span>{{ ruleForm.jqxCompany }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="交强险公司编码:">
            <span>{{ ruleForm.jqxCompanyCode }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="交强险起保日:" prop="jqxExpectBeginTime" v-if="isShow">
            <span>{{ ruleForm.jqxExpectBeginTime }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="交强险到期日:" prop="jqxExpectEndTime" v-if="isShow">
            <span>{{ ruleForm.jqxExpectEndTime }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="交强险性质:" prop="jqxInsuranceType" v-if="isShow">
            <span>
              {{ ruleForm.jqxInsuranceType == 1 ? '运营' : ruleForm.jqxInsuranceType == 2 ? '非运营' : '' }}
            </span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="交强险保费:" prop="jqxAmount" v-if="isShow">
            <span>{{ format_thousand(ruleForm.jqxAmount) }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="车船税是否缴纳:" prop="carTaxStatus" v-if="isShow">
            <span>{{
                ruleForm.carTaxStatus == '1' ? '是' : ruleForm.carTaxStatus == '2' ? '否' : ""
              }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8" v-if="ruleForm.carTaxStatus == 1">
          <el-form-item label="车船税:" prop="carTax" v-if="isShow">
            <span>{{ format_thousand(ruleForm.carTax) }}</span>
          </el-form-item>
        </el-col>
      </el-row>

    </el-card>
  </el-form>
</template>

<script>
export default {
  name: 'jqxWarrantyOfferApprove',//交强险保司报价审批
  dicts: ["insurance_channels"],
  props: {
    value: {
      type: Object,
      default: {},
    },
    state: {
      type: String,
      default: "",
    },
  },
  components: {
    insuranceSelect: () => import('../insuranceSelect')
  },
  computed: {
    ruleForm: {
      get() {
        let that = this;
        const proxy = new Proxy(that.value, {
          get(target, key) {
            return Reflect.get(target, key);
          },
          set(target, key, value) {
            if (value) {
              that.handleClearValidate(key)
            }
            that.$emit("input", {...target, [key]: value});
            return true;
          },
        });
        return proxy;
      },
    },
    labelPosition() {
      if (this.state === 'write') {
        return 'top'
      } else {
        return 'right'
      }
    },
    isEdit() {
      let bool;
      switch (this.state) {
        case "write":
          bool = true;
          break;
        case "disabled":
          bool = false;
          break;
        case "readonly":
          bool = false;
          break;
      }
      return bool
    }
  },
  data() {
    return {
      isShow: true,
    };
  },
  created() {
  },
  mounted() {
  },
  methods: {
    handleShopInsurace() {
      return new Promise((resolve, reject) => {
        this.$refs.ruleForm.validate((valid) => {
          if (valid) {
            resolve();
          } else {
            reject();
          }
        });
      });
    },
    // 店保金额格式
    changeTable(row, key, field) {
      let msg = /^(?:[1-9]\d*|0)(?:\.\d+)?$/;

      if (msg.test(Number(row[field]))) {
        if (Number(row[field]) >= 0) {
          let _value = row[field].toString().match(/^\d+(?:\.\d{0,2})?/)[0];
          row[field] = _value;
        } else {
          row[field] = "";
        }
      } else {
        row[field] = "";
      }
      // this.addAmountNun = this.addAmount(this.detailForm.carMaintainProjectList, 'price')
    },

    changeAmount(str) {
      let msg = /^(?:[1-9]\d*|0)(?:\.\d+)?$/;
      if (!msg.test(this.ruleForm[str])) {
        this.ruleForm[str] = "";
      } else {
        this.ruleForm[str] = this.ruleForm[str]
            .toString()
            .match(/^\d+(?:\.\d{0,2})?/)[0];
      }
    },

    handleChange(val) {
      this.value.jqxCompanyCode = val.code
      this.value.jqxCompany = val.name
      this.value.jqxCompanyId = val.id
      this.$refs.ruleForm.clearValidate('jqxCompany')
      this.$refs.ruleForm.clearValidate('jqxCompanyCode')
    },

    handleChange1(val) {
      this.value.syxCompanyCode = val.code
      this.value.syxCompany = val.name
      this.value.syxCompanyId = val.id
      this.$refs.ruleForm.clearValidate('jqxCompany')
      this.$refs.ruleForm.clearValidate('jqxCompanyCode')
    },

    //取消表单效验
    handleClearValidate(str) {
      this.$refs.ruleForm.clearValidate(str);
    },
    valid() {
      return new Promise((resolve) => {
        this.$refs.ruleForm.validate((valid) => {
          resolve(valid);
        });
      });
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/styles/cwgd/formScss.scss";
</style>



